<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <input type="text" id="txt">
  <select id="sel">
    <option value="1">普通会员</option>
    <option value="2">会员</option>
  </select>
  <div id="show"></div>
  <button id="btn">计算金额</button>
  <script>
    // 1.打印9*9 乘法表

    // for (var i = 1; i <= 9; i++) { // i  
    //   for (var j = 1; j <= i; j++) { // 1*1
    //     document.write(i + "*" + j + "=" + i * j + "&nbsp;&nbsp;")
    //   }
    //   document.write("<br/>")
    // }
    //
    // 2.顾客购物后，按以下规则进行结算，根据购物金额计算实付金额。
    // 普通会员购买100元		打9折
    // 会员购物			        8折
    // 会员购买200元 	      7折
    var btn = document.getElementById("btn");
    var show = document.getElementById("show");
    var txt = document.getElementById("txt");
    var sel = document.getElementById("sel");
    btn.onclick = function () {
      var money = txt.value;//获取金额；
      var power = sel.value;//获取会员的标识
      show.innerHTML = count(power, money);
    }
    function count(power, money) {
      var sum = 0;
      if (power == "1" && money >= 100) {
        sum = money * 0.9
      } else if (power == "2" && money >= 200) {
        sum = money * 0.7
      } else if (power == "2" && money < 200) {
        sum = money * 0.8
      } else {
        sum = "不打折"
      }
      return sum
    }


  </script>

</body>

</html>